package com.cyh.testdesignpattern.iterator;

import java.util.Iterator;

//计算机学院用数组存储专业
public class TComputerCollege implements TCollege {
    TDepartment[] tDepartments = new TDepartment[5];
    int numofTDepartment = 0;//保存当前数组的对象个数

    public TComputerCollege() {
        addTDpartment("java", "java111");
        addTDpartment("android", "android222");
        addTDpartment("c++", "c++3333");
    }

    @Override
    public String getName() {
        return "计算机学院";
    }

    @Override
    public void addTDpartment(String name, String desc) {
        TDepartment tDepartment = new TDepartment(name, desc);
        tDepartments[numofTDepartment] = tDepartment;
        numofTDepartment += 1;

    }

    @Override
    public Iterator createIterator() {
        return new ComputerCollegeIterator(tDepartments);
    }
}
